<template>
    <view class="container" :style="themeColor">
        <view class="main">
            <mescroll-uni
                @init="mescrollInit"
                :height="listHeight"
                :down="downOption"
                @down="refresh"
                :up="upOption"
                @up="getData">
                <!-- 数据列表 -->
                <feedback-list-item
                    :key="index"
                    v-for="(item, index) in datas"
                    :data="item"
                    @refreshBack="refreshBack"></feedback-list-item>
            </mescroll-uni>
            <view class="footer" @click="easyGoTo('/pages_me/packet/feedback/index')">反馈意见</view>
        </view>
    </view>
</template>

<script>
import { getElementHeight } from "@/uni-sub-base/utils/elementUtil.js"
import feedbackListItem from "@/pages_me/components/feedback/feedback-list-item.vue"
import { getFeedbackList } from "@/service/api/feedback.js"
export default {
    components: {
        feedbackListItem,
    },
    data() {
        return {
            datas: [],
            listHeight: 0,
            loadOk: false,
            isFrist: true,
            timer: null,
        }
    },
    mounted() {
        this.getListHeight()
        this.isFrist = false
    },
    onShow() {
        if (!this.isFrist) {
            this.refresh()
        }
    },
    methods: {
        getData(page) {
            let param = {
                pageSize: page.size,
                pageIndex: page.num,
            }
            let path = "?pageIndex=" + page.num + "&pageSize=" + page.size
            getFeedbackList(param, path).then((res) => {
                this.mescroll.endBySize(res.Data.length, res.RecordAmout)
                this.datas = this.datas.concat(res.Data)
            })
        },
        refresh() {
            this.datas = []
            this.mescroll.resetUpScroll()
        },
        getListHeight(element) {
            //获取商品高度
            getElementHeight(this, ".main", (e) => {
                this.listHeight = e - 60 + "px"
                this.loadOk = true
                //#ifndef MP
                this.refresh()
                //#endif
            })
        },
        //控制看大图关闭不重新加载
        refreshBack(e) {
            this.isFrist = e
            //延迟恢复
            if (this.timer) {
                clearTimeout(this.timer)
                this.timer = null
            }
            this.timer = setTimeout(() => {
                this.isFrist = false
            }, 3000)
        },
    },
}
</script>

<style lang="scss">
.footer {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 750rpx;
    height: 120rpx;
    background: #ffffff;
    box-shadow: 0px -2rpx 10rpx 0px rgba(0, 0, 0, 0.1);
    font-size: 32rpx;
    color: $color-gray-1;
    display: flex;
    justify-content: center;
    align-items: center;
}
</style>
